package com.zlzxm.shoesmarket.view.activity;

import android.content.Context;
import android.content.Intent;
import android.widget.NumberPicker;

import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;

import com.zlzxm.shoesmarket.R;
import com.zlzxm.shoesmarket.util.ZViewHelp;
import com.zlzxm.shoesmarket.view.widget.TendencyView;
import com.zlzxm.shoesmarket.view.widget.simpleead.SimpleHead;
import com.zlzxm.shoesmarket.viewmodel.VMTendency;
import com.zlzxm.shoesmarket.viewmodel.entity.EntityChartValue;

import java.util.List;


/**
 * CREATE BY zlzxm ON 4/25/21
 * 销售走势
 */
public class ACTendency extends BaseActivity{

    public static void start(Context context) {
        Intent starter = new Intent(context, ACTendency.class);
        context.startActivity(starter);
    }



    VMTendency vmTendency;

    private TendencyView tv1,tv2;


    @Override
    protected void initView() {
        super.initView();
        setContentView(R.layout.ac_tendency);
        SimpleHead simpleHead = ZViewHelp.findById(this,R.id.head);
        simpleHead.setTitle("销售走势");
        simpleHead.setOnItemclicklistener(this::finish);
        tv1  = ZViewHelp.findById(this,R.id.tv1);
        tv2  = ZViewHelp.findById(this,R.id.tv2);




    }

    @Override
    protected void initViewModule() {
        super.initViewModule();
        vmTendency = new ViewModelProvider(this).get(VMTendency.class);

        vmTendency.getLiveData().observe(this, new Observer<List<EntityChartValue>>() {
            @Override
            public void onChanged(List<EntityChartValue> entityChartValues) {
                tv1.setChartData(entityChartValues);
                tv2.setChartData(entityChartValues);
            }
        });
    }

    @Override
    protected void initData() {
        super.initData();
        vmTendency.getData();
    }
}
